{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "from podcastfy.client import generate_podcast"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "%pip install ipython\n",
    "from IPython.display import Audio, display\n",
    "\n",
    "def embed_audio(audio_file):\n",
    "\t\"\"\"\n",
    "\tEmbeds an audio file in the notebook, making it playable.\n",
    "\n",
    "\tArgs:\n",
    "\t\taudio_file (str): Path to the audio file.\n",
    "\t\"\"\"\n",
    "\ttry:\n",
    "\t\tdisplay(Audio(audio_file))\n",
    "\t\tprint(f\"Audio player embedded for: {audio_file}\")\n",
    "\texcept Exception as e:\n",
    "\t\tprint(f\"Error embedding audio: {str(e)}\")"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Generate a podcast from images"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Senecio, 1922 (Paul Klee) and Connection of Civilizations (2017) by Gheorghe Virtosu"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [],
   "source": [
    "conversation_config = {\n",
    "    \"roles_person1\": \"Abstract Art Ph.D. Professor\",\n",
    "    \"roles_person2\": \"Abstract Art Grad Student\",\n",
    "    \"podcast_name\": \"Artfy Podcast\",\n",
    "    \"podcast_tagline\": \"Because Art is Everywhere\",\n",
    "    \"creativity\": 1\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {},
   "outputs": [],
   "source": [
    "images = [\"https://raw.githubusercontent.com/souzatharsis/podcastfy/refs/heads/main/data/images/Senecio.jpeg\",\n",
    "          \"https://raw.githubusercontent.com/souzatharsis/podcastfy/refs/heads/main/data/images/connection.jpg\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 5,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating podcast...\n",
      "Transcript saved to ./data/transcripts/transcript_078f0148283e435989a60b456938bfda.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-11-16 11:22:08,434 - podcastfy.client - INFO - Podcast generated successfully using geminimulti TTS model\n"
     ]
    }
   ],
   "source": [
    "audio_file = generate_podcast(image_paths=images, \n",
    "                              tts_model=\"geminimulti\", \n",
    "                              conversation_config=conversation_config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "embed_audio(audio_file)\n",
    "#./data/audio/podcast_da40e428614945579ec1c9819cd4af5e.mp3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### The Great Wave off Kanagawa, 1831 (Hokusai) and Takiyasha the Witch and the Skeleton Spectre, c. 1844 (Kuniyoshi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "images = [\"https://raw.githubusercontent.com/souzatharsis/podcastfy/refs/heads/main/data/images/japan_1.jpg\",\n",
    "          \"https://raw.githubusercontent.com/souzatharsis/podcastfy/refs/heads/main/data/images/japan2.jpg\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "conversation_config = {\n",
    "    \"roles_person1\": \"Abstract Art Ph.D.\",\n",
    "    \"roles_person2\": \"Creative Abstract Artist\",\n",
    "    \"podcast_name\": \"Japan Arts Podcast\",\n",
    "    \"podcast_tagline\": \"Because Art is Everywhere\",\n",
    "    \"creativity\": 1,\n",
    "    \"user_instructions\": \"Speakers should often overlap in their sentences. The conversation should be about the relationship between art and life. Person2 should make connections with her own life!\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "/home/tobias/src/podcastfy-pypi/podcastfy/.venv/lib/python3.11/site-packages/tqdm/auto.py:21: TqdmWarning: IProgress not found. Please update jupyter and ipywidgets. See https://ipywidgets.readthedocs.io/en/stable/user_install.html\n",
      "  from .autonotebook import tqdm as notebook_tqdm\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating podcast...\n",
      "Transcript saved to ./data/transcripts/transcript_9ccfca254a584700ab325f6e65944b1c.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-11-16 13:02:35,134 - podcastfy.client - INFO - Podcast generated successfully using geminimulti TTS model\n"
     ]
    }
   ],
   "source": [
    "audio_file = generate_podcast(image_paths=images, \n",
    "                              tts_model=\"geminimulti\", \n",
    "                              conversation_config=conversation_config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "embed_audio(audio_file)\n",
    "#./data/audio/podcast_4917be8e74514dd0b3581d61e6719f38.mp3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Pop culture icon Taylor Swift and Mona Lisa, 1503 (Leonardo da Vinci)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 9,
   "metadata": {},
   "outputs": [],
   "source": [
    "images = [\"https://raw.githubusercontent.com/souzatharsis/podcastfy/refs/heads/main/data/images/taylor.png\",\n",
    "          \"https://raw.githubusercontent.com/souzatharsis/podcastfy/refs/heads/main/data/images/monalisa.jpeg\"]"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 10,
   "metadata": {},
   "outputs": [],
   "source": [
    "conversation_config = {\n",
    "    \"roles_person1\": \"Young Arts Ph.D.\",\n",
    "    \"roles_person2\": \"one of the most influential media figures and businesswomen of the modern era\",\n",
    "    \"podcast_name\": \"Podcastify\",\n",
    "    \"podcast_tagline\": \"Your Generative AI Podcast\",\n",
    "    \"creativity\": 1,\n",
    "    \"user_instructions\": \"Speakers should often overlap in their sentences. The conversation should be about the relationship between art and life. Person2 should make connections with her own life!\"\n",
    "}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating podcast...\n",
      "Transcript saved to ./data/transcripts/transcript_89f49ff34e3e44c7b15480959d16f162.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-11-16 13:08:41,907 - podcastfy.client - INFO - Podcast generated successfully using geminimulti TTS model\n"
     ]
    }
   ],
   "source": [
    "audio_file = generate_podcast(image_paths=images, \n",
    "                              tts_model=\"geminimulti\",\n",
    "                              conversation_config=conversation_config)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "embed_audio(audio_file)\n",
    "#./data/audio/podcast_0ed7b94e89e149ab9732494e4b18b3d7.mp3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [],
   "source": [
    "#audio_file = generate_podcast(urls=[\"../data/pdf/s41598-024-58826-w.pdf\"], \n",
    "#                              tts_model=\"geminimulti\")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {},
   "outputs": [],
   "source": [
    "#embed_audio(audio_file)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "## Generate a podcast from a Text"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Personal Website"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {},
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-11-16 13:11:16,106 - podcastfy.client - INFO - Processing 1 links\n"
     ]
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Generating podcast...\n",
      "Transcript saved to ./data/transcripts/transcript_08e8b0f295ea48e4aa44f1b17e007d82.txt\n"
     ]
    },
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "2024-11-16 13:11:44,927 - podcastfy.client - INFO - Podcast generated successfully using geminimulti TTS model\n"
     ]
    }
   ],
   "source": [
    "audio_file = generate_podcast(urls=[\"www.souzatharsis.com\"], \n",
    "                              tts_model=\"geminimulti\")\n",
    "#./data/transcripts/transcript_08e8b0f295ea48e4aa44f1b17e007d82.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "embed_audio(audio_file)\n",
    "#./data/audio/podcast_d3a3660df7d94a5991c905bff141322c.mp3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Book"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Benjamin Franklin's Autobiography (`longform=True`)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "audio_file = generate_podcast(urls=[\"https://www.gutenberg.org/cache/epub/20203/pg20203.txt\"], \n",
    "                              tts_model=\"geminimulti\",\n",
    "                              longform=True)\n",
    "#./data/transcripts/transcript_331c08ac7ef54623969a383f998c4bce.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "embed_audio(audio_file)\n",
    "#./data/audio/podcast_f1bc29aa1c1c42e98f83c6ea14b07add.mp3"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "### Youtube Video"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Lex Fridman Podcast: Dario Amodei Anthropic's CEO (`longform=True`)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": [
    "audio_file = generate_podcast(urls=[\"https://www.youtube.com/watch?v=ugvHCXCOmm4\"], \n",
    "                              tts_model=\"geminimulti\",\n",
    "                              longform=True)\n",
    "#./data/transcripts/transcript_0a4e53d85f9643f3a28bd59281e4e9cd.txt\n",
    "\n",
    "embed_audio(audio_file)\n",
    "#./data/audio/podcast_136cbe471d2c406395b13449b5bc44be.mp3"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": ".venv",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.11.10"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
